Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-parser

Package Overview
Dependencies
Maintainers
3
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser and validator for Node and browsers

  • 8.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
926K
decreased by-4.06%
Maintainers
3
Weekly downloads
 
Created

What is swagger-parser?

swagger-parser is a powerful npm package that allows you to parse, validate, and dereference Swagger (OpenAPI) definitions. It helps in ensuring that your API definitions are correct and can be used to resolve $ref pointers to simplify the API documentation.

What are swagger-parser's main functionalities?

Parse

This feature allows you to parse a Swagger (OpenAPI) definition file. The code sample demonstrates how to parse a Swagger file and log the API name and version.

const SwaggerParser = require('swagger-parser');

SwaggerParser.parse('path/to/your/swagger.yaml')
  .then(api => {
    console.log('API name: %s, Version: %s', api.info.title, api.info.version);
  })
  .catch(err => {
    console.error(err);
  });

Validate

This feature allows you to validate a Swagger (OpenAPI) definition file. The code sample demonstrates how to validate a Swagger file and log whether the API is valid or not.

const SwaggerParser = require('swagger-parser');

SwaggerParser.validate('path/to/your/swagger.yaml')
  .then(api => {
    console.log('API is valid:', api);
  })
  .catch(err => {
    console.error('API is invalid:', err);
  });

Dereference

This feature allows you to dereference $ref pointers in a Swagger (OpenAPI) definition file. The code sample demonstrates how to dereference a Swagger file and log the dereferenced API.

const SwaggerParser = require('swagger-parser');

SwaggerParser.dereference('path/to/your/swagger.yaml')
  .then(api => {
    console.log('Dereferenced API:', api);
  })
  .catch(err => {
    console.error(err);
  });

Bundle

This feature allows you to bundle all external $ref pointers into a single file. The code sample demonstrates how to bundle a Swagger file and log the bundled API.

const SwaggerParser = require('swagger-parser');

SwaggerParser.bundle('path/to/your/swagger.yaml')
  .then(api => {
    console.log('Bundled API:', api);
  })
  .catch(err => {
    console.error(err);
  });

Other packages similar to swagger-parser

Keywords

FAQs

Package last updated on 31 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc